3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
A set object (or, more briefly, a set) is a collection of zero or more elements, each of which has both an element type and some associated element data. QuickDraw 3D provides routines that you can use to create a new set, get the type of a set, add elements to a set, get the data associated with an element in a set, loop through all the elements in a set, and perform other operations on sets.
In general, you'll use the routines described in this section to handle sets containing elements with custom element types. You should use other QuickDraw 3D routines to handle sets that consist solely of elements with predefined element types. For example, to create a set of vertex attributes, you can use the Q3VertexAttributeSet_New function (to create a new empty set of vertex attributes) and the Q3AttributeSet_Add function (to add elements to that set). See the chapter "Attribute Objects" for information on managing attribute sets. See the section "Defining Custom Elements" for information on handling custom element types.
You can use the Q3Set_GetType function to get the type of a set.
TQ3ObjectType Q3Set_GetType (TQ3SetObject set);
The Q3Set_GetType function returns, as its function result, the type of the set specified by the set parameter. The type of set currently supported by QuickDraw 3D is defined by the constant:
kQ3SetTypeAttribute
If the type of the set cannot be determined or is invalid, Q3Set_GetType returns the value kQ3ObjectTypeInvalid .
You can use the Q3Set_Add function to add an element to a set.
TQ3Status Q3Set_Add (
TQ3SetObject set,
TQ3ElementType type,
const void *data);
The Q3Set_Add function adds the element specified by the type and data parameters to the set specified by the set parameter. The set must already exist when you call Q3Set_Add . Note that the element data is copied into the set. Accordingly, you can reuse the data parameter once you have called Q3Set_Add .
If the specified element type is a custom element type, Q3Set_Add uses the custom type's kQ3MethodTypeElementCopyAdd or kQ3MethodTypeElementCopyReplace custom methods. See the chapter "QuickDraw 3D Objects" for complete information on custom element types.
You can use the Q3Set_Get function to get the data associated with an element in a set.
TQ3Status Q3Set_Get (TQ3SetObject set, TQ3ElementType type, void *data);
The Q3Set_Get function returns, in the data parameter, the data currently associated with the element whose type is specified by the type parameter in the set specified by the set parameter. If no element of that type is in the set, Q3Set_Get returns kQ3Failure .
If you pass the value NULL in the data parameter, no data is copied back to your application. (Passing NULL might be useful simply to determine whether a set contains a specific type of element.)
If the specified element type is a custom element type, Q3Set_Get uses the custom type's kQ3MethodTypeElementCopyGet custom method. See the chapter "QuickDraw 3D Objects" for complete information on custom element types.
You can use the Q3Set_Contains function to determine whether a set contains an element of a particular type.
TQ3Boolean Q3Set_Contains (TQ3SetObject set, TQ3ElementType type);
You can use the Q3Set_GetNextElementType function to iterate through the elements in a set.
TQ3Status Q3Set_GetNextElementType (
TQ3SetObject set,
TQ3ElementType *type);
The Q3Set_GetNextElementType function returns, in the type parameter, the type of the element that immediately follows the element having the type specified by the type parameter in the set specified by the set parameter. To get the type of the first element in the set, pass kQ3ElementTypeNone in the type parameter. Q3Set_GetNextElementType returns kQ3ElementTypeNone when it has reached the end of the list of elements.
You can use the Q3Set_Empty function to empty a set of all the elements it contains.
TQ3Status Q3Set_Empty (TQ3SetObject target);
The Q3Set_Empty function removes all the elements currently in the set specified by the target parameter.
If the specified element type is a custom element type, Q3Set_Empty uses the custom type's kQ3MethodTypeElementDelete custom method. See the chapter "QuickDraw 3D Objects" for complete information on custom element types.
You can use the Q3Set_Clear function to remove an element of a certain type from a set.
TQ3Status Q3Set_Clear (TQ3SetObject set, TQ3ElementType type);
The Q3Set_Clear function removes the element whose type is specified by the type parameter from the set specified by the set parameter.
If the specified element type is a custom element type, Q3Set_Clear uses the custom type's kQ3MethodTypeElementDelete custom method. See the chapter "QuickDraw 3D Objects" for complete information on custom element types.
Previous | QD3D Book | Overview | Chapter Contents | Next |